#include <bits/stdc++.h>
#define int long long
#define maxn 100010
#define INF 0x3f3f3f3f3f3f3f3f

using namespace std;

int T, ans1 = 0, ans2 = 0;
int p[maxn];
struct node{
    int d, v, a;
    double S;
} car[maxn];

bool cmp(node x, node y) {
    return x.S > y.S;
}

signed main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> T;
    while (T--) {
        ans1 = 0, ans2 = 0;
        int n, m, L, V;
        cin >> n >> m >> L >> V;
        for (int i = 1; i <= n; i++) {
            cin >> car[i].d >> car[i].v >> car[i].a;
            car[i].S = (double)(V * V - car[i].v * car[i].v) / (double)(2 * car[i].a);
        }
        for (int i = 1; i <= m; i++) {
            cin >> p[i];
        }
        sort(p + 1, p + 1 + n);
        for (int i = 1; i <= n; i++) {
            if (car[i].v > (double)V && car[i].d <= p[n]) {
                ans1++;
            }
        }
        //((car[i].S >= (double)p[1]) && (car[i].S <= (double)p[n])) || (
        /*
        int lst = 0;
        for (int i = 1; i <= n; i++) {
            if (car[i].v > (double)V) {
                lst = max(lst, car[i].v);
            }
        }
        */
        sort(car + 1, car + 1 + n, cmp);
        set<int> st1;
        for (int i = 1; i <= m; i++) {
            for (int j = n; j >= 1 && car[j].S > p[i]; j--) {
                st1.insert(j);
            }
        }
        cout << ans1 << ' ' << m - st1.size() - 1 << '\n';
    }
    return 0;
}